
****************************************************************************
* ANALYSIS BY HIGH/LOW HOUSEHOLD BARGANING POWER INDICATORS
****************************************************************************
 use "data_acute_illness_patients_mixedlogit_vs4.dta", clear

* drop if no treatment information
drop if d_treat ==. 

* proxies for bargaining power
describe  income* weekly*

* summarize bargaining power indicators
sum age_diff agediff*
	 
tab agedifflargep50, miss
tab agedifflarge, miss
tab agedifflargep75, miss
	 
drop p_female
drop spouse

******************************************************************************************************
* TABLE A.9: Heterogeneity by bargaining power (above median age differences between husband and wife), 
* and robustness in terms of age of husband/wife, having more than 3 kid, wife's post-reproductive age
******************************************************************************************************

	 preserve 
	 set seed 5647825
	 *gen islam = (q01_16==3 & q01_16 <.)

	 *gen p_ = p_
	 gen p_lowbargain  = p_*agedifflarge
	 gen p_female = p_*female
	 gen p_female_lowbargain = p_*female*agedifflarge
	 	  
    * consider only the sample of spouses
	gen spouse = (relation_head==1 | relation_head==2)
	tab relation_head spouse
	
	 matrix b55g = b50[1,1..6], 0.0,  0.003, 0.26, 0.001, 0.0, 0.0, 0.0, 0.0,    0.001, 0.01, 0.0, 0.0, 0.0, 0.0, 0.0 
	 
	mixlogit d_  dist_dw_hf_2 dist_22   nu_8d alt2-alt4 nu_8dsq if spouse==1 , group(choicesit) id(idid) cluster(q01_10)  rand(doctor_tot  generator2009 beds p_  p_lowbargain p_female p_female_lowbargain ) from(b55g, copy)
	gen sample_with_braginingdata =  e(sample)	 
	*mixlogit d_  dist_dw_hf_2 dist_22   nu_8d alt2-alt4 nu_8dsq if spouse==1 & islam==1, group(choicesit) id(idid) cluster(hh_id09)  rand(doctor_tot  generator2009 beds p_  p_lowbargain p_female p_female_lowbargain ) from(b55g, copy)
	  
	 mixlpred PR0, nrep(500)
	 est store b1
    restore
	
	
	* AGE DIFFERENTIAL + price*(age of husband in hh) + price*(age of husband in hh)* female
	preserve
	set seed 5479023

	 *gen p_ = p_
	 gen p_lowbargain  = p_*agedifflarge
	 gen p_female = p_*female
	 gen p_female_lowbargain = p_*female*agedifflarge
	 gen p_agehusband = p_*agehh
	 gen p_agehusb_female = p_*agehh*female
	 	  
    * consider only the spouses
	gen spouse = (relation_head==1 | relation_head==2)
	tab relation_head spouse
	
	 matrix b56g = b50[1,1..6], 0.0, 0.003, 0.26, 0.001, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,     0.001, 0.01, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 
	 
	 mixlogit d_  dist_dw_hf_2 dist_22   nu_8d alt2-alt4  nu_8dsq if spouse==1 , group(choicesit) id(idid) cluster(q01_10) rand(doctor_tot  generator2009 beds p_  p_lowbargain p_female p_female_lowbargain p_agehusband p_agehusb_female) from(b56g, copy)
	  
	 mixlpred PR00, nrep(500)
	 est store a3 
    restore
	
	* AGE DIFFERENTIAL + price*(age of wife in hh) + price*(age of wife in hh)* female 
	preserve 
	set seed 5479023

	 *gen p_ = p_
	 gen p_lowbargain  = p_*agedifflarge
	 gen p_female = p_*female
	 gen p_female_lowbargain = p_*female*agedifflarge
	 gen p_agewife = p_*agess
	 gen p_agewife_female = p_*agess*female
	 	  
    * consider only the spouses
	gen spouse = (relation_head==1 | relation_head==2)
	tab relation_head spouse
	
	 matrix b56g = b50[1,1..6], 0.0, 0.003, 0.26, 0.001, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,     0.001, 0.01, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 
	 
	 mixlogit d_  dist_dw_hf_2 dist_22   nu_8d alt2-alt4 nu_8dsq if spouse==1 , group(choicesit) id(idid) cluster(q01_10)  rand(doctor_tot  generator2009 beds p_  p_lowbargain p_female p_female_lowbargain p_agewife p_agewife_female) from(b56g, copy)
	  
	 mixlpred PR00, nrep(500)
	 est store a2 
    restore
	
	
	* AGE DIFFERENTIAL + price*(# of children above median) + price*(# of children above median)* female
preserve
	collapse no_child altHF age if d_==1, by(id)
	sum no_child , det
	scalar median_no_child = r(p50)
	scalar list median_no_child
	count if no_child > median_no_child & no_child < .   /* 585/1701*/
	bys altHF: count if  no_child > median_no_child & no_child < .  
	bys altHF: count if  no_child < . 
restore

gen num_kids_above_median = (no_child > median_no_child)
 
	 preserve 
	 set seed 5479023
	 capture drop p_female spouse

	 *gen p_ = p_
	 gen p_lowbargain  = p_*agedifflarge
	 gen p_female = p_*female
	 gen p_female_lowbargain = p_*female*agedifflarge
	 gen p_num_kids_above_median  = p_*num_kids_above_median
	 gen p_female_num_kids_above_median = p_*female*num_kids_above_median
	 	  
    * consider only the sample of spouses
	gen spouse = (relation_head==1 | relation_head==2)
	tab relation_head spouse
	
	 matrix b56g = b50[1,1..6], 0.0,  0.003, 0.26, 0.001, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,     0.001, 0.01, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 
	 
	 mixlogit d_  dist_dw_hf_2 dist_22   nu_8d alt2-alt4 nu_8dsq if spouse==1 , group(choicesit) id(idid) cluster(q01_10)  rand(doctor_tot  generator2009 beds p_  p_lowbargain p_female p_female_lowbargain  p_num_kids_above_median p_female_num_kids_above_median ) from(b56g, copy)
	  	   
	 mixlpred PR00, nrep(500)
	 est store a1 
    restore
	
	
	* AGE DIFFERENTIAL + price*(women above reproductive age) + price*(women above reproductive age)* female
	preserve
	set seed 5479023
	
gen above_reproductive = (agess > 45 )

	 *gen p_ = p_
	 gen p_lowbargain  = p_*agedifflarge
	 gen p_female = p_*female
	 gen p_female_lowbargain = p_*female*agedifflarge
	 gen p_above_reproductive = p_*above_reproductive
	 gen p_above_reproductive_female = p_*above_reproductive*female
	 
    * consider only the spouses
	gen spouse = (relation_head==1 | relation_head==2)
	tab relation_head spouse
	
	 matrix b56g = b50[1,1..6], 0.0,  0.003, 0.26, 0.001, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,     0.001, 0.01, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 
	 
	 mixlogit d_  dist_dw_hf_2 dist_22   nu_8d  alt2-alt4  nu_8dsq if spouse==1 , group(choicesit) id(idid) cluster(q01_10) rand(doctor_tot  generator2009 beds p_  p_lowbargain p_female p_female_lowbargain p_above_reproductive p_above_reproductive_female) from(b56g, copy)
	  
	 mixlpred PR00, nrep(500)
	 est store a4
    restore
	
	
	
* Create a table for spouse

estout  b1 a3 a2 a1 a4 , style(tex)  replace   title("Gender heterogeneity: intra-household bargaining power - SPOUSE SAMPLE") ///
prehead(\begin{table}[htbp]\centering ///
\caption{{\sc @title}} ///
\begin{tabular}{l*{@M}{r}} ) ///
posthead("\hline\hline") prefoot("\hline") ///
stats(N r2 ll, fmt(%6.0f %8.3f %8.1f %8.3f) labels("N" "${R}^2$" "MLL" )) ///
varlabels( _cons "constant"  dist_dw_hf "distance" dist_22 "distance (squared)" nu_7d "residual CF" alt2 "public" alt3 "private" alt4 "doctors"  dist_2alt2 "distance X public" dist_2alt3 "distance X private "  dist_22_alt2 "distance (squared) X public" dist_22_alt3 "distance (squared) X private " doctor_tot "num doctors" generator2009 "generator" p_i1 "priceXq1" p_i2 "priceXq2" p_i3 "priceXq3" p_i4 "priceXq4"  p_i1_fem "priceXq1Xfemale" p_i2_fem "priceXq2Xfemale"  p_i3_fem "priceXq3Xfemale"  p_i4_fem "priceXq4Xfemale" p_ "price" p_lowbargain "price - low bargaining" p_female "price - female"  p_female_lowbargain "price - female - low bargaining" p_agewife "price - age of wife" p_agewife_female "price - age of wife - female" p_agehusband "price - age of husband" p_agehusb_female "price - age of husband - female" ) legend ///
cells(b(star fmt(%7.4f) ) se(par fmt(%6.3f))) ///
postfoot(\hline\hline\end{tabular} ///
\begin{minipage}{0.75\textwidth}\scriptsize{Notes: Clogit has bootstrapped standard errors (100 replications)}\end{minipage}\hfill\end{table}) ///
starlevels(* 0.1 ** 0.05 *** 0.01) 

